package com.spc.car.data.domain.project.po;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.spc.car.common.utils.StringUtils;
import com.spc.car.data.constant.CommConstants;
import com.spc.car.data.entity.project.ProjectTendering;
import com.spc.car.data.util.PageParam;
import lombok.Data;

/**
 * @author 12262
 */
@Data
public class QueryTenderSectionPO extends PageParam {
    /**
     * 标段编码
     */
    private String sectionCode;

    /**
     * 招标项目编码
     */
    private String projectTenderingCode;

    /**
     * 标段分类代码
     */
    private String sectionClassifyCode;

    /**
     * 投标人资质
     */
    private String bidderCqualified;

    /**
     * 标段名称
     */
    private String sectionName;

    public Wrapper toWrapper() {
        QueryWrapper<ProjectTendering> wrapper =
                new QueryWrapper<ProjectTendering>()
                        .like(StringUtils.isNotBlank(this.sectionName), "section_name", this.sectionName)

                        .eq(ObjectUtils.isNotNull(this.sectionCode), "section_code", this.sectionCode)

                        .eq(ObjectUtils.isNotNull(this.projectTenderingCode),"project_tendering_code", this.projectTenderingCode)

                        .eq(ObjectUtils.isNotNull(this.sectionClassifyCode), "section_classify_code", this.sectionClassifyCode)

                        .like(StringUtils.isNotBlank(this.bidderCqualified), "bidder_qualified", this.bidderCqualified)

                        .eq("status", CommConstants.TenderSections.Normal_Bid)

                        .orderByDesc("create_time");

        return wrapper;
    }
}
